<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>首页_蜗牛图书商城</title>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath }/css/index.css">
<script src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
<script>
	$(function() {
		//data --> json封装的goods对象
		//最新商品
		$.get("${pageContext.request.contextPath }/goods/findNew", "", function(data) {
			var $newest = $("#newest");
			var goodsData = data.data;
			var str = "";
			for(var i in goodsData) {
				str += '<li style="overflow: hidden">' +
							'<a href="${pageContext.request.contextPath}/goods/details?id='+goodsData[i].id+'" target="_blank">' +
								'<img src="${pageContext.request.contextPath}/'+goodsData[i].image+'" width="175" height="175" alt="'+ goodsData[i].name +'" title="'+ goodsData[i].name +'">' +
							'</a>' + 
							'<p class="pro_title">' + 
								'<a title="'+ goodsData[i].name +'" href="${pageContext.request.contextPath}/goods/details?id='+goodsData[i].id+'" target="_blank">'+ goodsData[i].name +'</a>' + 
							'</p>' + 
							'<p class="brown">惊喜价：￥' + 
								'<b>'+ goodsData[i].salesprice +'</b>' + 
							'</p>' +
							'<p class="light_gray"> 市场价： ￥'+
								'<del>'+ goodsData[i].marketprice +'</del>'+
							'</p>'+
						'</li>';
			}
			$newest.append(str);
		}, "json")
		
		
		//热门商品
		$.get("${pageContext.request.contextPath }/goods/findHot", "", function(data) {
			var $hot = $("#hot");
			var goodsData = data.data;
			var str = "";
			for(var i in goodsData) {
				str += '<li>' + 
							'<a href="${pageContext.request.contextPath}/goods/details?id='+goodsData[i].id+'" target="_blank">' +
								'<img src="'+ goodsData[i].image +'" height="85" alt="'+ goodsData[i].name +'" title="'+ goodsData[i].name +'">' +
							'</a>' +
							'<p class="pro_title">' + 
								'<a title="'+ goodsData[i].name +'" href="${pageContext.request.contextPath}/goods/details?id='+goodsData[i].id+'" target="_blank">'+ goodsData[i].name +'</a>' +
							'</p>' +
							'<p class="brown">￥' +
								'<b>'+ goodsData[i].marketprice +'</b>' +
							'</p>' +
						'</li>';
			}
			$hot.append(str);
		}, "json")
		
		//分类展示的IT技术...
		$.get("${pageContext.request.contextPath }/category/findAll", "", function(data) {
			var $category = $("#goodsType");
			var str = "";
			var categoryData = data.data;
			for(var i in categoryData) {
				str += '<li><a href="${pageContext.request.contextPath }/goods/findPageByCid?currentPage=1&cid='+ categoryData[i].id +'">'+ categoryData[i].name +'</a></li>';
				console.log(categoryData[i].name);
			}
			$category.append(str);
		}, "json")
	})
</script>
</head>

<body class="index">
	<div class="container">
		<div class="header" id="header">
			<h1 class="logo">
				<a title="" style="background: url(${pageContext.request.contextPath }/images/logo.png);"
					href="">电子商务平台</a>
			</h1>
			<c:if test="${not empty user }">
				<ul class="shortcut">
					<li class="first"><a href="${pageContext.request.contextPath }/personal/center">个人中心</a></li>
					<li><a href="${pageContext.request.contextPath }/personal/myOrders">我的订单</a></li>
				</ul>
				<p class="loginfo">
					你好${user.username }[<a href="${pageContext.request.contextPath }/user/quit">安全退出</a>]
				</p>
			</c:if>

			<c:if test="${empty user }">
				<p class="loginfo">
					[<a href="login.jsp">登录</a> <a class="reg" href="./register.jsp">免费注册</a>]
				</p>
			</c:if>

		</div>
		<div class="navbar">
			<ul id="goodsType">
				<li><a href="http://localhost:8080/book/">首页</a></li>
			</ul>
			<div class="mycart">
				<dl>
					<dt>
						<a href="${pageContext.request.contextPath}/cart/showCart">
							购物车<b name="mycart_nums" id="mycart_nums"></b>件
						</a>
					</dt>
					<dd>
						<a href="${pageContext.request.contextPath}/cart/order">去结算</a>
					</dd>
				</dl>
				<!--购物车浮动div 开始-->
				<div class="shopping" id="div_mycart" style="display: none;">
					<dl class="cartlist" id="shopcarDiv">
					</dl>
				</div>

			</div>
		</div>
		<div class="searchbar">
			<div class="allsort" id="goods_sort">
				<a href="javascript:void(0);">商品排行</a>
				<!--总的商品分类-开始-->
				<ul class="sortlist" id="div_allsort" style="display: none;">
					<li>
						<h2><a href="#" id="byName">按名称</a></h2>
					</li>
					<li>
						<h2><a href="#" id="bySaleNume">按销量</a></h2>
					</li>
					<li>
						<h2><a href="#" id="bySalespriceUp">价格升序</a></h2>
					</li>
					<li>
						<h2><a href="#" id="bySalespriceDown">价格降序</a></h2>
					</li>
				</ul>
			</div>
			<div class="searchbox">
					<input class="text" type="text" name="keyword" autocomplete="off" placeholder="输入关键字..." id="word" style="outline:none">
					<input class="btn" type="submit" value="商品搜索" id="search-btn">
			</div>
			<div class="hotwords">
				热门搜索：<a href="#">Java</a>
			</div>
		</div>

		<div class="wrapper clearfix">
			<div class="sidebar f_r">
				<!--热卖商品-->
				<div class="hot box m_10">
					<div class="title">
						<h2>热卖商品</h2>
					</div>
					<div class="cont clearfix">
						<ul class="prolist" id="hot">
							<!-- 热卖商品 -->
						</ul>
					</div>
				</div>
				<!--热卖商品-->
			</div>
			<div class="main f_l">
				<!--最新商品-->
				<div class="box yellow m_10">
					<div class="title title3">
						<h2>
							<img src="${pageContext.request.contextPath }/images/front/new_product.gif" alt="最新商品" width="160"
								height="36">
						</h2>
						<a class="more" href="goods.html?gtid=0">更多商品...</a>
					</div>
					<div class="cont clearfix">

						<ul class="prolist" id="newest">

							<!-- 最新商品的东西 -->

						</ul>
					</div>
				</div>

			</div>
		</div>
		<div class="help m_10">
			<div class="cont clearfix">
				<dl>
					<dt>
						<a href="">购物指南</a>
					</dt>
					<dd>
						<a href="">订单状态</a>
					</dd>
					<dd>
						<a href="">购物流程</a>
					</dd>
				</dl>
				<dl>
					<dt>
						<a href="">支付帮助</a>
					</dt>
					<dd>
						<a href="">支付帮助</a>
					</dd>
					<dd>
						<a href="">在线支付</a>
					</dd>
					<dd>
						<a href="">货到付款</a>
					</dd>
				</dl>
				<dl>
					<dt>
						<a href="">配送帮助</a>
					</dt>
					<dd>
						<a href="">EMS/邮政普包</a>
					</dd>
					<dd>
						<a href="">商品验货与签收</a>
					</dd>
					<dd>
						<a href="">配送范围及运费</a>
					</dd>
				</dl>
				<dl>
					<dt>
						<a href="">售后服务</a>
					</dt>
					<dd>
						<a href="">售后服务</a>
					</dd>
					<dd>
						<a href="">发票制度</a>
					</dd>
					<dd>
						<a href="">退货说明</a>
					</dd>
					<dd>
						<a href="">换货说明</a>
					</dd>
				</dl>
				<dl>
					<dt>
						<a href="">帮助信息</a>
					</dt>
					<dd>
						<a href="">友情链接</a>
					</dd>
					<dd>
						<a href="">联系客服</a>
					</dd>
					<dd>
						<a href="">找回密码</a>
					</dd>
					<dd>
						<a href="">关于我们</a>
					</dd>
				</dl>
			</div>
		</div>
		<div class="footer">
			<p class="links">
				<a href="">关于我们</a>|<a href="">常见问题</a>|<a href="">安全交易</a>|<a
					href="">购买流程</a>|<a href="">如何付款</a>|<a href="">联系我们</a>|<a href="">合作提案</a>
			</p>
			Copyright © 2015-2021 <a class="copyys" target="_blank" href="">蜀ICP备01000010号</a>
		</div>
	</div>
</body>
</html>